﻿using System;
using System.IO;

namespace HorrorsOfArkham.Game_Application_Layer
{
    public class TempFileHandler : FileHandler
    {
        #region Members

        public static readonly TempFileHandler Instance = new TempFileHandler();

        private string tempFileDirectory;

        public string TempFileDirectory
        {
            get
            { return tempFileDirectory; }
        }

        #endregion

        #region Initialization

        protected TempFileHandler()
        { 
        }

        public bool SetTempFileDirectory()
        {
            bool setupOK = false;

            string currentDir = Directory.GetCurrentDirectory();

            string newTempDirectory = currentDir + "\\TempFiles";

            if (!Directory.Exists(@newTempDirectory))
            {
                Directory.CreateDirectory(newTempDirectory);

                if (Directory.Exists(@newTempDirectory))
                {
                    tempFileDirectory = newTempDirectory;
                    setupOK = true;
                }
                else
                {
                    setupOK = false;
                }
 
            }
            else 
            {
                tempFileDirectory = newTempDirectory;
                setupOK = true;
            }

            return setupOK;
        }

        #endregion
    }
}
